<!-- 剧情介绍 -->
<template>
	<view class="plotIntroduction_content">
		<z-paging ref="paging" :default-page-size="100" :refresher-end-bounce-enabled="false" 
		:refresher-complete-duration="300" :refresher-complete-delay="500" v-model="dataList" @query="queryList" 
		:fixed="false" :auto="false" loading-more-no-more-text="已经到底线了">
			<view class="box" v-for="(item,index) in dataList" :key="index" @click="clickToItem(item)">
				<view class="box_image_con">
					<image class="image" :src="item.thumbnail||item.cover" mode="aspectFill"></image>
				</view>
				<view class="box_info_con">
					<view class="box_info_conInfo">
						<view class="box_info_conInfo_titleT">{{ item.name }}</view>
						<view class="box_info_conInfo_desT">{{ item.remark }}</view>
					</view>
					<view class="box_info_con_checkAll_con">
						<view class="box_info_con_checkAll_con_t">查看全部</view>
					</view>
				</view>
			</view>
		</z-paging>
	</view>
</template>

<script>
	import interfaces from "@/utils/interfaces.js"
	import config from "@/utils/config.js"
	export default {
		components:{
		},
		data() {
			return {
				dataList:[],
				firstLoaded: false		
			}
		},
		props:{
			//当前组件的index，也就是当前组件是swiper中的第几个
			tabIndex: {
				type: Number,
				default: function(){
					return 0
				}
			},
			//当前swiper切换到第几个index
			currentIndex: {
				type: Number,
				default: function(){
					return 0
				}
			},
			data: {
				type: Object,
				default: function(){
					return {}
				}
			}
		},
		watch: {
			currentIndex: {
				handler(newVal) {
					if(newVal === this.tabIndex){
						//懒加载，当滑动到当前的item时，才去加载
						if(!this.firstLoaded){
							setTimeout(() => {
								this.$refs.paging.reload();
							}, 100);
						}
					}
				},
				immediate: true
			},
		},
		methods: {
			queryList(pageNum, pageSize) {
				// console.log("当前" + pageNum + "-" + pageSize)
				let id = this.data.id
				let url = interfaces.square_block_rankinglist + id + ".json";
				let self = this
				self.request({
					url:url,
					methods:"GET",
					success:(res)=> {
						// console.log(res)
						self.dataList = res.content[0].lists
						self.$refs.paging.complete(self.dataList)
						self.firstLoaded = true
					},
					fail:(error)=> {
						console.log("错误 错误 错误:" + error + ":" + url)
					}
				})				
				// uni.showLoading({
				// 	title:"加载中..."
				// })
				// let _this = this
				// setTimeout(function() {
				// 	uni.hideLoading()
				// 	if (pageNum == 1) {
				// 		_this.dataList = []
				// 	} else if (pageNum == 3) {
				// 		_this.dataList1.pop()
				// 	}
				//   _this.$refs.paging.complete(_this.dataList1)
				//   _this.firstLoaded = true
				//   _this.dataList = _this.dataList.concat(_this.dataList1)
				// }, 1000);				
			},
			clickToItem(item){
				let data = JSON.stringify(item)
				uni.navigateTo({
					url:'/pages/tabBar/square/plotIntroduction/plotDetails/plotDetails?data=' + data
				})
			},
		}
	}
</script>

<style lang="scss">
	/* 注意:父节点需要固定高度，z-paging的height:100%才会生效 */
	.plotIntroduction_content {
		height: 100%;
		
		.box{
			display: flex;
			box-sizing: border-box;
			width: 100%;
			height: 255rpx;
			padding: 0px 15px;
			margin: 15px 0px;
			// background-color: orange;
			
			.box_image_con{
				display: flex;
				flex-shrink: 0; //设置flex元素所有比例.默认是1,为0的时候不进行缩放
				width: 200rpx;
				height: 100%;
				border-radius: 15px;
				// background-color: blue;
				.image{
					width: 100%;
					height: 100%;
					border-radius: 15px;
				}
			}
			
			.box_info_con{
				display: flex;
				box-sizing: border-box;
				flex-direction: column;
				width: 100%;
				// background-color: darkgreen;
				margin: 5px 0px 0px 12px;
				
				.box_info_conInfo{
					display: flex;
					box-sizing: border-box;
					flex-direction: column;
					width: 100%;
					// background-color: purple;
					
					.box_info_conInfo_titleT{
						display: flex;
						white-space: nowrap;
						overflow: hidden;
						text-overflow: ellipsis;
						font-size: 18px;
					}
					.box_info_conInfo_desT{
						display: -webkit-box;
						-webkit-line-clamp: 2;
						-webkit-box-orient: vertical;
						overflow: hidden;
						text-overflow: ellipsis;
						margin-top: 10px;
						font-size: 16px;
						color: #999DA2;
					}
				}
				
				.box_info_con_checkAll_con{
					display: flex;
					justify-content: flex-end;
					margin-top: 15px;
					// background-color: greenyellow;
					.box_info_con_checkAll_con_t{
						width: 150rpx;
						height: 45rpx;
						line-height: 45rpx;
						text-align: center;
						font-size: 15px;
						color: #D98A47;
						border: 1rpx solid #D98A47;
						border-radius: 75rpx;
					}
					
				}
				
			}
		}
	}	
</style>